#define _CRT_SECURE_NO_WARNINGS 1
#include<stdlib.h>

struct TreeNode {
      int val;
    struct TreeNode *left;
    struct TreeNode *right;
};
int maxDepth(struct TreeNode* root) {
    if (root == NULL)
    {
        return 0;
    }
    int leftdepth = maxDepth(root->left);
    int rightdepth = maxDepth(root->right);

    return leftdepth > rightdepth ? leftdepth + 1 : rightdepth + 1;
}